<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of base_model
 *
 * @author faroq
 */
class base_model extends MY_MODEL {

    //put your code here
    function __construct() {
        parent::__construct();
    }

    //put your code here

    function daftar_siswa_rows($search="",$where="",$start,$limit) {
        $sql_search="";
        if ($search != "") {
            $sql_search = "(lower(nis) LIKE '" . strtolower($search) . "%' or lower(nama) LIKE '%" . strtolower($search) . "%')";
//            $this->db->where($sql_search, NULL);
        }
        if ($where != ""){
            if ($sql_search != "") {
                $sql_search=$sql_search." and ".$where;
            }else{
                $sql_search=$where;
            }
        }
        $select="id_siswa, nis, nama, ayah, ibu, alamat, telepon, seluler, tempat_lahir, tgl_lahir, th_masuk, th_alumni, jenis_kelamin, kd_kelas, kelas, tinggi, berat";
        $order=array("kd_kelas,nis", "asc");     
        $table="v_daftarsiswa";
        
        $results = $this->get_rows_paging($sql_search,$start,$limit,$table,$select,$order);
        return $results;       
        
    }  
    
    function daftar_siswa_print($search="",$where="") {
        $sql_search="";
        if ($search != "") {
            $sql_search = "(lower(nis) LIKE '" . strtolower($search) . "%' or lower(nama) LIKE '%" . strtolower($search) . "%')";
//            $this->db->where($sql_search, NULL);
        }
        if ($where != ""){
            if ($sql_search != "") {
                $sql_search=$sql_search." and ".$where;
            }else{
                $sql_search=$where;
            }
        }
        $select="id_siswa, nis, nama, ayah, ibu, alamat, telepon, seluler, tempat_lahir, tgl_lahir, th_masuk, th_alumni, jenis_kelamin, kd_kelas, kelas, tinggi, berat";
        $order=array("kd_kelas,nis", "asc");     
        $table="v_daftarsiswa";
        
        $results = $this->get_rows_table_array($sql_search,$table,$select,$order);
        return $results;       
        
    }  
    
    function get_thajaran_aktif(){
        $sql_search="";
        $select="id_th_ajaran, tahun_ajaran, semester";
        $order=NULL;     
        $table="v_thajaran_aktif";
        
        $results = $this->get_rows_table_array($sql_search,$table,$select,$order);
        return $results;      
        
    }
    
    function biaya_siswa_print($search="") {
        $sql_search="";
        if ($search != "") {
            $sql_search = $search;
        }
        $select="nis,nama,kd_kelas,kelas,kd_biaya,biaya,biaya_dasar,biaya_dikenakan";
        $order=array("kd_kelas,nis,order_biaya", "asc");     
        $table="v_biaya_siswa";
        
        $results = $this->get_rows_table_array($sql_search,$table,$select,$order);
        return $results;       
        
    }  
    
    function potongan_print($search="") {
        $sql_search="";
        if ($search != "") {
            $sql_search = $search;
        }
        $select="nis, nama, kd_kelas, kelas, kd_biaya, biaya, potongan, keterangan, th_ajaran_mulai, thbl_mulai, thbl_selesai";
        $order=array("thbl_mulai,nis,order_biaya", "asc");     
        $table="v_potongan";
        
        $results = $this->get_rows_table_array($sql_search,$table,$select,$order);
        return $results;       
        
    }  
    
    function saldopiutang_print($search="") {
        $sql_search="";
        if ($search != "") {
            $sql_search = $search;
        }
        $select="thbl,nis,nama,semester,kd_kelas,kelas,kd_biaya,biaya,id_jenis,fgroup,biaya_dikenakan,total_potongan,detail_potongan,total_biaya,pelunasan,saldo";
        $order=array("thbl,kd_kelas,nis,id_jenis,order_biaya", "asc");     
        $table="v_piutang_aktif_join";
        
        $results = $this->get_rows_table_array($sql_search,$table,$select,$order);
        return $results;       
        
    }  
    function payment_print($search="") {
        $sql_search="";
        if ($search != "") {
            $sql_search = $search;
        }
        $select="trx_id, thblbayar, tglbayar, thbl, nis, nama, id_th_ajaran, tahun_ajaran, semester, kd_kelas, kelas, keterangan, kd_biaya, biaya, id_jenis, jenis_biaya, biaya_dikenakan, total_potongan, detail_potongan, total_biaya, saldoawal, pelunasan, saldoakhir, id_piutang_siswa, trx_id_bank, teller_bank, tglcatat, catat_by, fgroup, order_biaya";
        $order=array("kd_kelas,nis,id_jenis,order_biaya,tglbayar", "asc");     
        $table="v_piutang_pay";
        
        $results = $this->get_rows_table_array($sql_search,$table,$select,$order);
        return $results;       
        
    }  

}

?>
